import org.aswing.plaf.custom.css.AbstractParser;
import org.aswing.plaf.custom.css.DefaultValues;
import org.aswing.plaf.ASFontUIResource;


class org.aswing.plaf.custom.css.ApplicationParser extends AbstractParser
{
	
	private static var UIDEF_SYSTEM_FONT:String = "systemFont"
	private static var UIDEF_MENU_FONT:String = "menuFont"
	private static var UIDEF_CONTROL_FONT:String = "controlFont"
	private static var UIDEF_WINDOW_FONT:String = "windowFont"
	
	public static function parse(block):Array{
		var result:Array = [];
		
		//font parsing
		var fontSize = block[CSS_FONT_SIZE];
		var fontName = block [CSS_FONT];
		var allFonts:Array = [UIDEF_SYSTEM_FONT, UIDEF_MENU_FONT,UIDEF_CONTROL_FONT, UIDEF_WINDOW_FONT]			
		if(fontName != null){
			if(fontSize != null){	
				for (var i=0; i < allFonts.length; i++) 
					result = concat(result,[allFonts[i],new ASFontUIResource(fontName,fontSize)]);	
			}else{			
				for (var i=0; i < allFonts.length; i++) 
					result = concat(result,[allFonts[i],new ASFontUIResource(fontName,DefaultValues.FONT_SIZE)]);				
			}
		}else if(fontSize != null){
			for (var i=0; i < allFonts.length; i++) 
					result = concat(result,[allFonts[i],new ASFontUIResource(DefaultValues.FONT,fontSize)]);
		}
		
		return result;
	}
}
